<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>文档标题</title>
    <style>
        .bg-white {
            background: white;
        }

        .bg-pink {
            background: pink;
        }

        li {
            display: block;
            padding: 5px 10px;
        }
    </style>
</head>
<body>
<ul id="list">
    <li>apple</li>
    <li>banana</li>
    <li>orange</li>
    <li>pear</li>
    <li>peach</li>
</ul>

<script>

  window.onload = function () {
    const list = document.getElementById("list");
    list.onclick = event => {
      for (const li of list.children) {
        li.className = "bg-white";
      }
      event.target.className = "bg-pink";
    }
  }
</script>
</body>
</html>
